home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Framework Interfaces / AEFutures.h next >
Text File  |  1996-05-22  |  3KB  |  94 lines

  1. // Sprocket Framework header file
  2. // AEFutures.h
  3.  
  4.  
  5.  
  6. #ifndef _Futures_
  7. #define _Futures_
  8.  
  9. #ifndef __MIXEDMODE__
  10. #include <MixedMode.h>
  11. #endif
  12. #ifndef __APPLEEVENTS__
  13. #include <AppleEvents.h>
  14. #endif
  15. #ifndef __THREADS__
  16. #include <Threads.h>
  17. #endif
  18.  
  19. //
  20. // Constants
  21. //
  22. #define kNoMaximumWait                    (0x7FFFFFFF)
  23.  
  24. #if 0
  25.  
  26. //
  27. // Keyword for refCon attribute not documented
  28. // in Inside Macintosh
  29. //
  30. #define keyRefconAttr                    'refc'
  31.  
  32. #endif
  33.  
  34. //
  35. // Keyword keyAEResetTimerFrequency specifies
  36. // approximately how frequently (in ticks) the 
  37. // client would like the server to call AEResetTimer.
  38. // This value is advisory only, and is typically
  39. // one-half of the timeout value.
  40. //
  41. #define keyAEResetTimerFrequencyAttr     'resf'
  42.  
  43. //
  44. // This is how frequently a server should call
  45. // AEResetTimer if the AppleEvent message doesn't
  46. // contain a 'reset timer frequency' attribute
  47. //
  48. #define kDefaultResetTimerFrequency        30
  49.  
  50. //
  51. // Values for InitFutures
  52. //
  53. #define kNoSpecialFutureFeatures        0
  54. #define kSpawnHousekeepingThread        0x0001
  55. #define kInstallAsyncPreDispatchHandler    0x0002
  56. #define kAllSpecialFutureFeatures        (kSpawnHousekeepingThread | kInstallAsyncPreDispatchHandler)
  57.  
  58. typedef pascal OSErr (*ThreadCreateProcPtr)(ThreadEntryProcPtr threadEntry, void* threadParam, long handlerRefCon, ThreadID* threadMade);
  59.  
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63.  
  64. //
  65. // Prototypes for Future functions
  66. //
  67. OSErr InitFutures(ThreadCreateProcPtr threadCreateProc, long initFuturesFlags);
  68. void BlockUntilReal(AppleEvent* reply);
  69. Boolean ReplyArrived(AppleEvent* reply);
  70. void SetReplyTimeoutValue(AppleEvent* reply, long timeoutValue, long maxWaitTime);
  71. void IdleFutures();
  72. OSErr AskForFuture(AppleEvent* ae, AppleEvent* reply, long timeoutValue, long maxWaitTime, AESendMode sendMode, AESendPriority sendPriority);
  73. long GetResetTimerFrequency(AppleEvent* ae);
  74. OSErr ResetTimerIfNecessary(AppleEvent* reply, unsigned long* lastReset, long resetFrequency);
  75.  
  76. #ifdef __cplusplus
  77. }
  78.  
  79. //
  80. // Default parameters: for use with C++ compilers
  81. //
  82. inline OSErr InitFutures(ThreadCreateProcPtr threadCreateProc = nil /* kAllSpecialFutureFeatures */) { return InitFutures(threadCreateProc, kAllSpecialFutureFeatures); }
  83. inline OSErr AskForFuture(AppleEvent* ae, AppleEvent* reply, long timeoutValue = kAEDefaultTimeout, long maxWaitTime = kNoMaximumWait, AESendMode sendMode = 0 /* kAENormalPriority */) { return AskForFuture(ae, reply, timeoutValue, maxWaitTime, sendMode, kAENormalPriority); }
  84.  
  85. #endif
  86.  
  87. //
  88. // Backwards compatability API
  89. //
  90. #define IsFuture(reply)        (!ReplyArrived(reply))
  91.  
  92. #endif // Futures_h
  93.  
  94.